<?php

/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/Project for the canonical source repository
 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */

namespace Project;

use Project\Model\projectview;
use Project\Model\projectviewTable;
use Project\Model\Project;
use Project\Model\ProjectTable;
use Project\Model\Task;
use Project\Model\TaskTable;
use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;



class Module 
{
    public function getAutoloaderConfig()
    {
        return array(
            'Zend\Loader\ClassMapAutoloader' => array(
                __DIR__ . '/autoload_classmap.php',
            ),
            'Zend\Loader\StandardAutoloader' => array(
                'namespaces' => array(
		    // if we're in a namespace deeper than one level we need to fix the \ in the path
                    __NAMESPACE__ => __DIR__ . '/src/' . str_replace('\\', '/' , __NAMESPACE__),
                ),
            ),
        );
    }

    public function getConfig()
    {
        return include __DIR__ . '/config/module.config.php';
    }
	public function getServiceConfig()
    {
        return array(
            'factories' => array(
                'Project\Model\projectviewTable' =>  function($sm) {
                    $tableGateway = $sm->get('projectviewTableGateway');
                    $table = new projectviewTable($tableGateway);
                    return $table;
                },
                'Project\Model\ProjectTable' =>  function($sm) {
                	$tableGateway = $sm->get('ProjectTableGateway');
                	$table = new ProjectTable($tableGateway);
                	return $table;
                },
                'Project\Model\TaskTable' =>  function($sm) {
                	$tableGateway = $sm->get('TaskTableGateway');
                	$table = new TaskTable($tableGateway);
                	return $table;
                },
                
                'projectviewTableGateway' => function ($sm) {
                    $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                    $resultSetPrototype = new ResultSet();
                    $resultSetPrototype->setArrayObjectPrototype(new projectview());
                    return new TableGateway('projectview', $dbAdapter, null, $resultSetPrototype);
                },
                'ProjectTableGateway' => function ($sm) {
                	$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                	$resultSetPrototype = new ResultSet();
                	$resultSetPrototype->setArrayObjectPrototype(new Project());
                	return new TableGateway('Project', $dbAdapter, null, $resultSetPrototype);
                },
                'TaskTableGateway' => function ($sm) {
                	$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                	$resultSetPrototype = new ResultSet();
                	$resultSetPrototype->setArrayObjectPrototype(new Task());
                	return new TableGateway('Task', $dbAdapter, null, $resultSetPrototype);
                },
                
            ),
        );
    }
}
